#include "type.h"

/* Power control bit */
#define TIMER2_POWERON  (1 << 22)

/* TCR Register */
#define TIMER_ENABLE    (1 << 0)
#define TIMER_RESET     (1 << 1)

#define TIMER_FRQ_10MHZ        10000000
#define TIMER_FRQ_1MHZ         1000000
#define TIMER_FRQ_500KHZ       500000
#define TIMER_FRQ_400KHZ       400000
#define TIMER_FRQ_200KHZ       200000
#define TIMER_FRQ_100KHZ       100000

#define TIMER_FRQ_VALUE        TIMER_FRQ_200KHZ

#define COUNTER_TURNAROUND_20MS 8000

#define MR0_INTERRUPT_ENABLED  (1 << 0)
#define MR0_RESET_TC           (1 << 1)

/* Count control register */
#define TIMER_MODE_PC_MATCH    0x00
#define TIMER_MODE_CAP_RISING  0x01
#define TIMER_MODE_CAP_FALLING 0x02
#define TIMER_MODE_CAP_BOTH    0x03

void timer2_init (void);
void timer2_isr(void);

